/** 
 * @Title: TransFormDao.java 
 * @Package com.zizo.autohome.word.transform 
 * @Description: TODO
 * @author HeYan
 * @date 2016年9月22日 下午4:12:03 
 */
package com.zizo.autohome.word.transform;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.zizo.util.ConnectionPool;

/**
 * @ClassName: TransFormDao
 * @Description: TODO
 * @author HeYan
 * @date 2016年9月22日 下午4:12:03
 * 
 */
public class TransFormDao {
	private Connection conn = ConnectionPool.getConnection("Projects_2016", "localhost");

	public List<Integer> getCarID() {
		List<Integer> list = new ArrayList<>();
		Statement st = null;
		ResultSet rs = null;
		String sql = "SELECT Projects_2016.brand_models_alias.CarID as id FROM Projects_2016.brand_models_alias";
		try {
			st = conn.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				getClubID(rs.getInt(1));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public void getClubID(int carid) {
		Statement st = null;
		ResultSet rs = null;
		String sql = "SELECT brand_autohomeClubId FROM carvoice_core.core_brand_autohome WHERE brand_autohomeId="
				+ carid;
		try {
			st = conn.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				updateClubID(carid, rs.getInt(1));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void updateClubID(int carid, int clubid) {
		Statement st = null;
		String sql = "UPDATE Projects_2016.brand_models_alias SET ClubID=" + clubid + " WHERE CarID=" + carid;
		try {
			st = conn.createStatement();
			st.executeUpdate(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		String s1 = "�";
		String s2 = "�";
		System.out.println(s1.equals(s2));
	}
}
